// Nicholas Lineback

#include <iostream>
#include <getopt.h>
#include <fstream>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  int 
    c,
    option_index = 0;
  bool
    science = false,
    integer = true;
  char 
    *fileName;

  while(1)
  {
    static struct option long_options[] = 
      {
	{"scientific",    no_argument, 0, 's'},
	{"integer",       no_argument, 0, 'i'},
	{0,0,0,0}
      };
    c = getopt_long(argc,
		    argv,
		    "si",
		    long_options,
		    &option_index);
    if( c == -1)
    {
      break;
    }
    switch(c)
    {
    case 's':
      science = true;
      break;
    case 'i':
      integer = true;
      break;
    default:
      abort();
    }
    fileName = argv[optind];
  }
  std::ofstream file;
  
  if( science )
  {
    int 
      A = 0,
      B = 32*10000,
      C = 2*B;
    
    file.open(fileName);
    file << std::hex;
    for( int i = 0; i < 100; i++ )
    {
      for( int j = 0; j < 100; j++ )
      {
	for( int k = 0; k < 100; k++ )
	{
	  file << A + 32*i*100 + k*32 << " r" << std::endl;
	  file << B + 32*k*100 + j*32 << " r" << std::endl;
	}
	file << C + 32*i*100 + j*32 << " w" << std::endl;
      }
    }
    file.close();
  }
  else
  {
    int 
      addresses[1000],
      randint1,
      randint2;
    file.open(fileName);
    file << std::hex;
    for( int i = 0; i < 100; i++)
    {
      addresses[i*10] = abs(rand()%1000000000 + 1000)*32;
      for( int j = 1; j < 10; j++)
      {
	addresses[i*10 + j] = addresses[i*10] + rand()%100*32;
      }
    }
    for( int i = 0; i < 100000; i++ )
    {
      randint1 = abs(rand()%100);
      for( int j = 0; j < 10; j++)
      {
	randint2 = abs(rand()%4);
	if( randint2 > 0 )
	{
	  file << addresses[randint1*10 + j] << " r\n";
	}
	else
	{
	  file << addresses[randint1*10 + j] << " w\n";
	}
      }
    }
    file.close();
  }
}


